//
//  NightManager.m
//  夜间模式
//
//  Created by dllo on 15/4/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "NightManager.h"
#define BLACK [UIColor darkGrayColor]
#define WHITE [UIColor whiteColor]
#import "NightMode.h"

@implementation NightManager

+ (void)setLabelColorWithLabel:(UILabel *)label {
    
    if ([NightMode shareNightMode].isNight) {
        label.textColor = WHITE;
    } else {
        label.textColor = BLACK;
    }
}

+ (void)setViewColorWithView:(UIView *)view{
    if ([NightMode shareNightMode].isNight) {
        view.backgroundColor = BLACK;
    } else {
        view.backgroundColor = WHITE;
    }
}

+ (void)setButtonTitleColorWithButton:(UIButton *)button {
    if ([NightMode shareNightMode].isNight) {
        [button setTitleColor:WHITE forState:UIControlStateNormal];
    } else {
        [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    }
}

+ (void)setBackgroundColorWithView:(UIView *)backView {
    if ([NightMode shareNightMode].isNight) {
        backView.backgroundColor = BLACK;
    } else {
        backView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:240/255.0];
    }
}

+ (void)setBackgroundColorWithWebView:(UIWebView *)webView{
    if ([NightMode shareNightMode].isNight) {
        [webView stringByEvaluatingJavaScriptFromString:@" document.body.style.background = '#2E2E2E';"];
#pragma mark 两种方式
        [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'white';"];
    } else {
        [webView stringByEvaluatingJavaScriptFromString:@" document.body.style.background = 'white';"];
#pragma mark 两种方式
        [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= '#2E2E2E';"];
    }
}

@end
